<?php require VIEWPATH. ADMIN_DIR. DIRECTORY_SEPARATOR. 'header.php'?>
<style type="text/css">
	
</style>
<div class="page-header">
	<h1>班级荣誉管理</h1>
</div>
<!-- 教师权限不可筛选 -->
<?php if($rmxUser['user_type'] != USER_TYPE_TEACHER): ?>
	<div class="col-xs-12 content-filter">
		<div class="widget-box">
			<div class="widget-header">
				<h4 class="widget-title">内容筛选</h4>
				<div class="widget-toolbar">
					<a href="#" data-action="collapse">
						<i class="ace-icon fa fa-chevron-up"></i>
					</a>
					<a href="#" data-action="close">
						<i class="ace-icon fa fa-times"></i>
					</a>
				</div>
			</div>
			<div class="widget-body">
				<div class="widget-main">
					<div class="form-inline" id="data-search">
						<div class="form-inline keyword-search-div">
							<label class="keyword-search-label">年级</label>
							<div class="keyword-search-box">
								<a href="javascript:;" class="keyword-search-keyword keyword-search-grade active" data-id="0">全部</a>
								<?php foreach($gradeList as $grade): ?>
									<a href="javascript:;" class="keyword-search-keyword keyword-search-grade" data-id="<?=$grade['id']?>"><?=$grade['grade_name']?></a>
								<?php endforeach; ?>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
<?php endif ?>

<div class="col-xs-12">
	<table id="dynamic-table" class="table table-striped table-bordered table-hover" style="margin-top:10px">
		<thead>
			<tr>
				<th>班级名称</th>
				<th>班级荣誉管理</th>
			</tr>
		</thead>
		<tbody>
		</tbody>
	</table>
</div>

<?php require VIEWPATH. ADMIN_DIR. DIRECTORY_SEPARATOR. 'footer.php'?>
<script type="text/javascript">
	$(function(){
		// 班级表格
		var table = $('#dynamic-table').dt({
			"ajaxUrl": '<?=admin_url('contents/get_honor_class_list')?>',
			"columns": [
	            {"data": "className"},
	            {"data": function(ret){
	            	var action = '';
	            	action += '<a class="edit-grade green" href="<?=admin_url('contents/honor_list')?>/'+ ret.id +'"><i class="fa fa-edit"></i> 查看荣誉列表</a>';
	                return action;
	            }},
			]
		});
		// 点击关键字
		$("body").on("click", ".keyword-search-keyword", function(){
			var id = $(this).data("id");
			// 高亮当前点击对象
			$(this).parent().find(".keyword-search-keyword").removeClass("active");
			$(this).addClass("active");
			// 筛选年级	
			table.setAjaxData({
				"gradeId": $(this).data('id')
			});
		})
	})
</script>